// Copyright (C)2012 Johann Duscher. All rights reserved.
//
// This file is part of QwTAPI.
//
// QwTAPI is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// QwTAPI is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with QwTAPI.  If not, see <http://www.gnu.org/licenses/>.

#pragma once

#include "stdafx.h"
#include "CallInfo.h"
#include "CallStatus.h"


namespace qwtapi
{

class Line;
class Address;
class Request;

class QWTAPI_EXPORT Call : public QObject
{
    Q_OBJECT

    typedef QObject super;

    friend class Line;

public:
    Line* getLine() const;

    HCALL getCallHandle() const;
    const CallInfo& getCallInfo(LONG* pResult = 0) const;
    const CallStatus& getCallStatus(LONG* pResult = 0) const;
    Address* getAddress(LONG* pResult = 0) const;

    LONG drop(const QString& userUserInfo = "");
    LONG accept(const QString& userToUser = "");
    LONG setPrivilege(CallPrivilege::Constant callPrivilege);
    LONG setMediaMode(MediaMode::Constants mediaModes);

protected:
    Call(Line *pLine, HCALL hCall);
    ~Call();

    void initialize();
    LONG deallocate();

protected slots:
    void onDropResult(const Request* pRequest);
    void onAcceptResult(const Request* pRequest);

private:
    HCALL m_hCall;

    mutable CallInfo m_callInfo;
    mutable CallStatus m_callStatus;
};

}
